using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Object_PlayerBullet : ObjectBulletBase
{
    [SerializeField] private int penetrateCount = 3;
    private int penetrate;
    public void SetupBullet(Vector2 direction, float damage, float moveSpeed)
    {
        float angle = Mathf.Atan2(direction.y, direction.x) * Mathf.Rad2Deg;
        transform.rotation = Quaternion.AngleAxis(angle, Vector3.forward);

        _damage = damage;

        isDamage = false;

        penetrate = penetrateCount;

        rb.velocity = direction * moveSpeed;

        moveDir = direction;
    }
    public Vector2 GetCurrentBulletSpeed() => rb.velocity;

    protected override void OnTriggerEnter2D(Collider2D other)
    {
        base.OnTriggerEnter2D(other);

        if (isDamage == false)
            return;

        penetrate--;

        isDamage = false;

        if (penetrate <= 0)
            PoolManager.Instance.Delease(gameObject);
    }
}
